var balance;

$(function () {
    var url = localStorage.url+'/boss/develop/income/show';
    var devId = localStorage.id;
    $.ajax({
        type: "get",//请求方式,post\get只要在这里改，其他地方不要改
        url: url,//访问的地址
        data: {did:devId},// 要提交的数据,
        dataType:'json',//传入数据的格式，可以统一用json
        success: function (msg) {
            console.log(msg);
            data=msg;
            $('#balance').html("￥"+data['data1']);
            $('#financeMangeTable').DataTable({
                data:data['data2'],
                columns:[
                    {title:"日期"},
                    {title:"提现金额"},
                    {title:"提现后余额"},
                    {title:"状态"}
                ]
            });



        },
        error: function (error) {

        }
    });

});

function withdraw() {

    var url=localStorage.url;
    var devId = localStorage.id;
    $('#devId2').val(devId);
    var obj = $('#withdrawForm').serialize();//表单序列化
    console.log(obj);
    $.ajax({
        type: "get",//请求方式,post\get只要在这里改，其他地方不要改
        url: url+"/boss/develop/income/withdraw",//访问的地址
        data: obj,// 要提交的数据,
        dataType:'json',
        success: function (msg) {
            console.log(msg);
            console.log(msg[devId]);
            if(msg[devId] == "apply successful"){
                $('#frame').load('devFinanceManage.html');
            }else{
                alert("余额不足，提现失败");
            }


        },
        error: function (error) {
            console.log(error);
            alert('..提交失败！');
        }
    });
}